package com.ruoyi.volunteer_college.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.volunteer_college.domain.TbVolunteerCollege;
import com.ruoyi.volunteer_college.service.ITbVolunteerCollegeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 志愿院校信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/volunteer_college/volunteer_college")
public class TbVolunteerCollegeController extends BaseController
{
    @Autowired
    private ITbVolunteerCollegeService tbVolunteerCollegeService;

    /**
     * 查询志愿院校信息列表
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVolunteerCollege tbVolunteerCollege)
    {
        startPage();
        List<TbVolunteerCollege> list = tbVolunteerCollegeService.selectTbVolunteerCollegeList(tbVolunteerCollege);
        return getDataTable(list);
    }

    /**
     * 导出志愿院校信息列表
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:export')")
    @Log(title = "志愿院校信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVolunteerCollege tbVolunteerCollege)
    {
        List<TbVolunteerCollege> list = tbVolunteerCollegeService.selectTbVolunteerCollegeList(tbVolunteerCollege);
        ExcelUtil<TbVolunteerCollege> util = new ExcelUtil<TbVolunteerCollege>(TbVolunteerCollege.class);
        util.exportExcel(response, list, "志愿院校信息数据");
    }

    /**
     * 获取志愿院校信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbVolunteerCollegeService.selectTbVolunteerCollegeById(id));
    }

    /**
     * 新增志愿院校信息
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:add')")
    @Log(title = "志愿院校信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVolunteerCollege tbVolunteerCollege)
    {
        return toAjax(tbVolunteerCollegeService.insertTbVolunteerCollege(tbVolunteerCollege));
    }

    /**
     * 修改志愿院校信息
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:edit')")
    @Log(title = "志愿院校信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVolunteerCollege tbVolunteerCollege)
    {
        return toAjax(tbVolunteerCollegeService.updateTbVolunteerCollege(tbVolunteerCollege));
    }

    /**
     * 删除志愿院校信息
     */
    @PreAuthorize("@ss.hasPermi('volunteer_college:volunteer_college:remove')")
    @Log(title = "志愿院校信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVolunteerCollegeService.deleteTbVolunteerCollegeByIds(ids));
    }
}
